﻿using System.Windows;
using GalaSoft.MvvmLight.Messaging;
using WhiteRepositoryExplorer.Messeges;
using WhiteRepositoryExplorer.ViewModel;
using WhiteRepositoryExplorer.Views;

namespace WhiteRepositoryExplorer
{
    /// <summary>
    /// This application's main window.
    /// </summary>
    public partial class MainWindow : Window
    {
        private AboutWindow _adoutWindow;

        /// <summary>
        /// Initializes a new instance of the MainWindow class.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
            Closing += (s, e) => ViewModelLocator.Cleanup();
            Loaded += (s, e) =>
            {
                _adoutWindow = new AboutWindow(this);
            };

            Messenger.Default.Register<ShowAboutWindowMessage>(this, (msg) => _adoutWindow.ShowDialog());
            Messenger.Default.Register<HideAboutWindowMessage>(this, (msg) => _adoutWindow.Hide());
            Messenger.Default.Register<FocusFilterMessage>(this, (msg) => TextBoxFilter.Focus());

        }
    }
}